package br.com.iswe.core.web.spring;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.dao.DataAccessResourceFailureException;

public class OpenSessionInViewFilter extends org.springframework.orm.hibernate3.support.OpenSessionInViewFilter {

	private static final Log log = LogFactory.getLog(OpenSessionInViewFilter.class);
	
	public OpenSessionInViewFilter(){
		super();
		if(log.isInfoEnabled()){
			log.info("OpenSessionInViewFilter Wrapper : Hibernate Session FlushMode alterado para : FlushMode.AUTO");
		}
	}
	
	@Override
	protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException {
		Session retorno = super.getSession(sessionFactory);
		retorno.setFlushMode(FlushMode.AUTO);
		return retorno;
	}
	
}
